package com.naiterui.ehp.bs.cms.modules.inventory.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.security.annotation.SysLog;
import com.naiterui.ehp.bs.cms.common.vo.PageParamsVO;
import com.naiterui.ehp.bs.cms.common.vo.PageVO;
import com.naiterui.ehp.bs.cms.modules.inventory.service.IInventoryService;
import com.naiterui.ehp.bs.cms.modules.inventory.vo.InventoryWaterVO;
import com.naiterui.ehp.bs.cms.modules.inventory.vo.SkuInventoryVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Validated
@RestController
@Api(tags = {SwaggerTag.CMS + SwaggerTag.MEDICINE_DRUG})
@RequestMapping("inventory")
public class InventoryController {

  @Autowired
  private IInventoryService inventoryService;

  @SysLog("库存查询")
  @GetMapping("/list")
  @ApiOperation("库存查询")
  @PreAuthorize("@p.check('inventory:list')")
  public PageVO<SkuInventoryVO> list(PageParamsVO pageParamsVO, SkuInventoryVO skuInventory) {
    return this.inventoryService.queryPage(pageParamsVO, skuInventory);
  }

  @SysLog("库存流水查询")
  @GetMapping("/water/list")
  @ApiOperation("库存流水查询")
  @PreAuthorize("@p.check('inventory:water:list')")
  public PageVO<InventoryWaterVO> listWater(PageParamsVO pageParamsVO, InventoryWaterVO inventoryWaterVO) {
    return this.inventoryService.queryWaterPage(pageParamsVO, inventoryWaterVO);
  }

}
